<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加模型</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="admin.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
</head>
<body>

<div class="container">
    <form name="spot_model" id="spot_model" action="module.php?m=spot&s=model_spot.php" method="post">
        <input type="hidden" name="spot_id_up" value="<{$spot_id}>"/>
        <div id="delete"></div>
        <div class="type_list">
                <table class="table4">
                    <thead>
                    <tr>
                        <td width="120">区域名称</td>
                        <td width="60">价格</td>
                        <td width="30" class="ac">显示</td>
                        <td width="50" class="ac">排序</td>
                        <td width="50" class="ac">操作</td>
                    </tr>
                    </thead>
                    <tbody>
                    <{foreach item=vo key=num from=$list}>
                    <tr>
                        <input type="hidden" name="ids[]" value="<{$vo.id}>"/>
                        <td><input type="text" name="model_name[]" class="model_name" value="<{$vo.model_name}>" size="40" /></td>
                        <td><input type="text" name="price[]" class="model_name" value="<{$vo.price}>" class="w50" /></td>
                        <td class="ac"><input type="checkbox" <{if $vo.statu==1}>checked="checked"<{/if}> value="1" name="statu[]" /></td>
                        <td><input type="text" class="w50" maxlength="3" name="displayorders[]" value="<{$vo.displayorders}>" /></td>
                        <td class="ac"><div><a href="javascript:;" class="deleterow" onclick="deleterows(this,<{$vo.id}>)">删除</a>   &nbsp;&nbsp;&nbsp;<a class="addtr"  data-id="<{$vo.id}>" data-spot-id="<{$vo.spot_id}>" id="seat"  href="javascript:void();">座位</a></div></td>
                    </tr>
                    <{/foreach}>
                    <tr>
                        <td colspan="99">
                            <ul class="button">
                                <li class="button">
                                    <a class="a_button" onClick="addrows(this,0)" href="javascript:void(0);">添加一个区域</a>
                                </li>
                            </ul>
                        </td>
                    </tr>
                    </tbody>
                </table>
        </div>

        <div class="dialog_button">
            <input id="property_button" type="button" value="保存">
            <input name="act" type="hidden" value="act">
        </div>
    </form>
    <span id="error"></span>
    <script>

        $("#property_button").click(function(){
                $("#spot_model").submit();
            window.parent.close('spot_model');
        });

            var rowtypedata = [
                [
                    ['<input type="text" name="model_name[]" size="40" value="" />'],
                    ['<input type="text" name="price[]" class="model_name" value="" />'],
                    ['<input type="checkbox" checked="checked" value="1" name="statu[]">','ac'],
                    ['<input type="text" maxlength="3" class="w50" name="displayorders[]" value="255" />'],
                    ['<div><a href="javascript:;" class="deleterow" onClick="deleterows(this)">删除</a></div>','ac'],

                ],

            ];
            var addrowdirects = 0;
            var j = 1;
            function addrows(obj, type) {
                var table = obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
                if(!addrowdirects) {
                    var row = table.insertRow(obj.parentNode.parentNode.parentNode.parentNode.rowIndex);
                } else {
                    var row = table.insertRow(obj.parentNode.parentNode.parentNode.parentNode.rowIndex + addrowdirects);
                }
                var typedata = rowtypedata[type];
                for(var i = 0; i <= typedata.length - 1; i++) {

                    var cell = row.insertCell(i);
                    if(typedata[i][1]) {
                        cell.className = typedata[i][1];
                    }
                    var tmp = typedata[i][0];
                    if(type==0)
                        tmp = tmp.replace(/\{(n)\}/g, function($1) { return j;});
                    else
                        tmp = tmp.replace(/\{(n)\}/g, function($1, $2) {return addrows.arguments[2];});
                    cell.innerHTML = tmp;
                }
                addrowdirects = 0;
                if(type==0) { j++; }
            }
            function deleterows(obj,id) {
                var table = obj.parentNode.parentNode.parentNode.parentNode.parentNode;
                var tr = obj.parentNode.parentNode.parentNode;
                table.deleteRow(tr.rowIndex);
                var html = '<input type="hidden" name="delete_id[]" value="'+id+'" />';
                $("#delete").append(html);

            }

        $("#seat").live('click',function(){
            var model_id = $(this).attr('data-id');
            var data_spot_id = $(this).attr('data-spot-id');
            window.parent.iframe_form("spot_seat", '添加座位', '<{$config.weburl}>/admin/module.php?m=spot&s=spot_seat.php'+'&model_id='+model_id+'&spot_id='+data_spot_id, 800, 600);
            return false;
        });


    </script>
</div>



</body>
</html>
